package com.cloudree.gllib.surface;

import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.opengl.GLSurfaceView;

/**
 * Created by Administrator on 2017/8/1.
 */
public class BaseGLSurface extends GLSurfaceView {

    public BaseGLSurface(Context context) {
        super(context);
        if (isGLSupported(context)){
            setEGLContextClientVersion(2);//gles20
        }else {
            throw new RuntimeException("This device is not supported !");
        }
    }


    /**
     * check whether gl i
     */
    public boolean isGLSupported(Context context) {
        ActivityManager mManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo mConfigurationInfo=mManager.getDeviceConfigurationInfo();
        return mConfigurationInfo.reqGlEsVersion>=0x2000;
    }
}
